﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvoAlgLib
{
    public class FuncFactory
    {
        public Func randomFunc()
        {
            int r = LibStatics.getRandomizer().Next(7);
            switch (r)
            {
                case 0:
                    return new AddFunc();
                case 1:
                    return new SubFunc();
                case 2:
                    return new MulFunc();
                case 3:
                    return new DivFunc();
                case 4:
                    return new SinFunc();
                case 5:
                    return new CosFunc();
                case 6:
                    return new ILTEFunc();
                default:
                    return null; // should never happen
            }
        }

        public Func randomLiteral()
        {
            int r = LibStatics.getRandomizer().Next(4);
            switch (r)
            {
                case 0:
                    return new ConstFunc(LibStatics.getRandomizer().NextDouble());
                case 1:
                    return new ConstFunc(-LibStatics.getRandomizer().NextDouble());
                case 2:
                    return new VarFunc("x");
                case 3:
                    return new VarFunc("y");
                default:
                    return new ConstFunc(LibStatics.getRandomizer().NextDouble());
            }
        }
    }
}
